import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * Date:2021年9月22日 下午3:06:14
 * Copyright (c) 2021, www.bwbroad.com All Rights Reserved
 */

/**
 * Description: TODO <br/>
 * Date:2021年9月22日 下午3:06:14 <br/>
 * 
 * @author xuejianxin
 */
public class JsonTest {

	public static void main(String[] args) throws IOException {
		String jsonStr = Files
				.readAllLines(Path.of("C:/Program Files/feiq/Recv Files/", "增值税发票返回信息.txt"), Charset.forName("UTF-8"))
				.stream().collect(Collectors.joining());
		//System.out.println(jsonStr);
		System.out.println(
				
		Optional.of(jsonStr)
		.map(json -> {return (JSONObject) JSONObject.parse(json);})
		.map((JSONObject jo)->{return (JSONArray) jo.get("words_result11"); } )
		.map(ja->ja.toJavaList(JSONObject.class))
		.flatMap(arr-> Optional.ofNullable ( arr.stream()))
		//.get()
		.map((Object jo)-> ( (JSONObject) jo).get("result"))
		.map((Object jo)-> ( (JSONObject) jo).get("Password"))
		//.collect(Collectors.toList())
		//.orElse("111")
		
		);
		
		

	}

}
